package com.xianrenit.xianrenpuzi.manager.service.impl;

import com.xianrenit.xianrenpuzi.manager.mapper.CategoryBrandMapper;
import com.xianrenit.xianrenpuzi.manager.service.CategoryBrandService;
import com.xianrenit.xianrenpuzi.model.entity.product.Brand;
import com.xianrenit.xianrenpuzi.model.entity.product.CategoryBrand;
import com.xianrenit.xianrenpuzi.model.vo.sys.CategoryBrandVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryBrandServiceImpl implements CategoryBrandService {
    @Resource
    CategoryBrandMapper categoryBrandMapper;
    @Override
    public PageInfo list(CategoryBrand categoryBrand, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<CategoryBrandVo> categoryBrandVoList = categoryBrandMapper.selectByCondition(categoryBrand);
        return new PageInfo(categoryBrandVoList);
    }

    @Override
    public void deleteById(Long id) {
        categoryBrandMapper.deleteById(id);
    }

    @Override
    public void save(CategoryBrand categoryBrand) {
        categoryBrandMapper.save(categoryBrand);
    }

    @Override
    public CategoryBrand getById(Long id) {
        return  categoryBrandMapper.getById(id);
    }

    @Override
    public void update(CategoryBrand categoryBrand) {
        categoryBrandMapper.update(categoryBrand);
    }

    @Override
    public List<Brand> listBrandsByC3id(Long c3id) {

        return categoryBrandMapper.listBrandsByC3id(c3id);
    }
}
